﻿<UserControl x:Class="BBInterfaceNET.Toolbox.Views.ToolboxView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:b="clr-namespace:BBInterfaceNET.Toolbox.Behaviors"
             mc:Ignorable="d" 
             d:DesignHeight="100" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/BBInterfaceNET.Toolbox;component/Resources/ExpanderStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Background="DarkBlue">
            <TextBlock Text="Toolbox" FontWeight="Black" Foreground="White"
                       Margin="5,2" FontSize="12"/>
        </Border>
        <ListBox Grid.Row="1" ItemsSource="{Binding Path=Items}" Background="#efefef">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="1">
                        <i:Interaction.Behaviors>
                            <b:DragStartBehavior/>
                        </i:Interaction.Behaviors>
                        <Image Source="/BBInterfaceNET.Toolbox;component/Resources/item.png"
                               Width="22" VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding Description}" Margin="2,1" VerticalAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.GroupStyle>
                <GroupStyle >
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander Header="{Binding Path=Name}" IsExpanded="True"
                                                      HorizontalContentAlignment="Stretch"
                                                      HorizontalAlignment="Stretch">
                                            <Expander.HeaderTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding}" Margin="5,2"/>
                                                </DataTemplate>
                                            </Expander.HeaderTemplate>
                                            <ItemsPresenter></ItemsPresenter>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListBox.GroupStyle>
        </ListBox>
    </Grid>
</UserControl>
